﻿#ifndef DDUMSGTEST_H
#define DDUMSGTEST_H

#include <Common/commondef.h>
#include <Common/teststatusmodel.h>
#include <Tool/websocketclient.h>
#include <QIcon>
#include <QWidget>
#include <Tool/qxlsxhelper.h>
#include <Tool/tcpclient.h>
#include<dataCache/trdpprotocal.h>
#include <include/paddleocr.h>
#include"Tool/trdpConfig.h"
#include"Common/configData.h"
#include"formconfigtrdp.h"

namespace Ui {
class DDUMsgTest;
}

class   trdpTestThread;
class DDUMsgTest : public QWidget
{
    Q_OBJECT

public:
    explicit DDUMsgTest(QWidget *parent = nullptr);
    ~DDUMsgTest();

signals:
    void SendLogMsg(const QString& logMsg,int ntype=0);
    void SendStatusInfo(const TestStatusModel& status);
private:
    void InitUI();
    bool loadDataofDDU(QString strFileName);
    void Readconfig(const QString& configSheetName);
    void ConnectAllSlots();
    void ConfigWindowsSplit();
public slots:
private slots:
    void on_pushButton_loadExcel_clicked();
    void on_pushButton_PDFExport_clicked();
    void on_pushButton_pause_clicked();
    void on_pushButton_Start_clicked();
    void on_pushButton_stop_clicked();
    void on_pushButton_Snap_clicked();
    void on_pushButton_configTRDP_clicked();
    void on_pushButton_OCRtest_clicked();

    void OnWorkFinish(int ncdoe);
    void OnStepFinish(int id,bool bResult,QString testInfo);
    void OnReceiveOCRImg(QByteArray byteArray);
    void OnStartOCR();
    void OnProcedureMsg(const QString& msg);
    void OnStatusInfoUpdate(int nid,QTime& time,bool bWork);
    void showDDUProtocal(const QMap<QString,QList<QString>>& DDUProtocal);
    void SlotReceiveTcpServerReply(const QString& msg);

private:
    Ui::DDUMsgTest *ui;

    trdpTestThread *thread=nullptr;      //测试线程
    QMap<QString,QList<QString>> DDUProtocalData;      //数据内容
    QVector<TRDPconfig> _trdpCongigs;       //trdp 配置内容

    qxlsxHelper xlsxhelper;             //excel文件读写接口
    WebsocketClient* websocketClient = nullptr;

    TestStatusModel _statusInfo;         //状态栏信息缓存
    bool bSnap = false;             //用于过滤线程事件

    QString _protocalSheetName;
    QString _configSheetName;
    //显示测试的条数
    int _nShowLine=5;
    FormConfigTRDP* _configTRDP =nullptr;
};

#endif // DDUMSGTEST_H
